﻿using System.Collections.Generic;
using System.Linq;

namespace EstateNuke.Data
{
    public partial class EstateNukeCore
    {
        #region AgreementState

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<AgreementState> GetAllAgreementStates()
        {
            return GetAllAgreementStates(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<AgreementState> GetAllAgreementStates(bool withoutDeleted)
        {
            IQueryable<AgreementState> agreementStates = AgreementStates;
            if (withoutDeleted)
            {
                agreementStates = agreementStates.Where(agreementState => agreementState.IsDeleted == false);
            }
            agreementStates = agreementStates.OrderBy(agreementState => agreementState.Id);
            return agreementStates.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public AgreementState GetAgreementStateById(int id)
        {
            return GetAgreementStateById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public AgreementState GetAgreementStateById(int id, bool withoutDeleted)
        {
            var agreementStates = AgreementStates.Where(agreementState => agreementState.Id == id);
            if (withoutDeleted)
            {
                agreementStates = agreementStates.Where(agreementState => agreementState.IsDeleted == false);
            }
            return agreementStates.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public AgreementState GetAgreementStateByName(string name)
        {
            return GetAgreementStateByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public AgreementState GetAgreementStateByName(string name, bool withoutDeleted)
        {
            var agreementStates = AgreementStates.Where(agreementState => agreementState.Name == name);
            if (withoutDeleted)
            {
                agreementStates = agreementStates.Where(agreementState => agreementState.IsDeleted == false);
            }
            return agreementStates.FirstOrDefault();
        }

        #endregion

        #region AlertType

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<AlertType> GetAllAlertTypes()
        {
            return GetAllAlertTypes(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<AlertType> GetAllAlertTypes(bool withoutDeleted)
        {
            IQueryable<AlertType> alertTypes = AlertTypes;
            if (withoutDeleted)
            {
                alertTypes = alertTypes.Where(alertType => alertType.IsDeleted == false);
            }
            alertTypes = alertTypes.OrderBy(alertType => alertType.Id);
            return alertTypes.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public AlertType GetAlertTypeById(int id)
        {
            return GetAlertTypeById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public AlertType GetAlertTypeById(int id, bool withoutDeleted)
        {
            var alertTypes = AlertTypes.Where(alertType => alertType.Id == id);
            if (withoutDeleted)
            {
                alertTypes = alertTypes.Where(alertType => alertType.IsDeleted == false);
            }
            return alertTypes.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public AlertType GetAlertTypeByName(string name)
        {
            return GetAlertTypeByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public AlertType GetAlertTypeByName(string name, bool withoutDeleted)
        {
            var alertTypes = AlertTypes.Where(alertType => alertType.Name == name);
            if (withoutDeleted)
            {
                alertTypes = alertTypes.Where(alertType => alertType.IsDeleted == false);
            }
            return alertTypes.FirstOrDefault();
        }

        #endregion

        #region BuildingState

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<BuildingState> GetAllBuildingStates()
        {
            return GetAllBuildingStates(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<BuildingState> GetAllBuildingStates(bool withoutDeleted)
        {
            IQueryable<BuildingState> buildingStates = BuildingStates;
            if (withoutDeleted)
            {
                buildingStates = buildingStates.Where(buildingState => buildingState.IsDeleted == false);
            }
            buildingStates = buildingStates.OrderBy(buildingState => buildingState.Id);
            return buildingStates.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public BuildingState GetBuildingStateById(int id)
        {
            return GetBuildingStateById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public BuildingState GetBuildingStateById(int id, bool withoutDeleted)
        {
            var buildingStates = BuildingStates.Where(buildingState => buildingState.Id == id);
            if (withoutDeleted)
            {
                buildingStates = buildingStates.Where(buildingState => buildingState.IsDeleted == false);
            }
            return buildingStates.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public BuildingState GetBuildingStateByName(string name)
        {
            return GetBuildingStateByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public BuildingState GetBuildingStateByName(string name, bool withoutDeleted)
        {
            var buildingStates = BuildingStates.Where(buildingState => buildingState.Name == name);
            if (withoutDeleted)
            {
                buildingStates = buildingStates.Where(buildingState => buildingState.IsDeleted == false);
            }
            return buildingStates.FirstOrDefault();
        }

        #endregion

        #region BuildingType

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<BuildingType> GetAllBuildingTypes()
        {
            return GetAllBuildingTypes(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<BuildingType> GetAllBuildingTypes(bool withoutDeleted)
        {
            IQueryable<BuildingType> buildingTypes = BuildingTypes;
            if (withoutDeleted)
            {
                buildingTypes = buildingTypes.Where(buildingType => buildingType.IsDeleted == false);
            }
            buildingTypes = buildingTypes.OrderBy(buildingType => buildingType.Id);
            return buildingTypes.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public BuildingType GetBuildingTypeById(int id)
        {
            return GetBuildingTypeById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public BuildingType GetBuildingTypeById(int id, bool withoutDeleted)
        {
            var buildingTypes = BuildingTypes.Where(buildingType => buildingType.Id == id);
            if (withoutDeleted)
            {
                buildingTypes = buildingTypes.Where(buildingType => buildingType.IsDeleted == false);
            }
            return buildingTypes.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public BuildingType GetBuildingTypeByName(string name)
        {
            return GetBuildingTypeByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public BuildingType GetBuildingTypeByName(string name, bool withoutDeleted)
        {
            var buildingTypes = BuildingTypes.Where(buildingType => buildingType.Name == name);
            if (withoutDeleted)
            {
                buildingTypes = buildingTypes.Where(buildingType => buildingType.IsDeleted == false);
            }
            return buildingTypes.FirstOrDefault();
        }

        #endregion

        #region BusinessType

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<BusinessType> GetAllBusinessTypes()
        {
            return GetAllBusinessTypes(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<BusinessType> GetAllBusinessTypes(bool withoutDeleted)
        {
            IQueryable<BusinessType> businessTypes = BusinessTypes;
            if (withoutDeleted)
            {
                businessTypes = businessTypes.Where(businessType => businessType.IsDeleted == false);
            }
            businessTypes = businessTypes.OrderBy(businessType => businessType.Id);
            return businessTypes.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public BusinessType GetBusinessTypeById(int id)
        {
            return GetBusinessTypeById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public BusinessType GetBusinessTypeById(int id, bool withoutDeleted)
        {
            var businessTypes = BusinessTypes.Where(businessType => businessType.Id == id);
            if (withoutDeleted)
            {
                businessTypes = businessTypes.Where(businessType => businessType.IsDeleted == false);
            }
            return businessTypes.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public BusinessType GetBusinessTypeByName(string name)
        {
            return GetBusinessTypeByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public BusinessType GetBusinessTypeByName(string name, bool withoutDeleted)
        {
            var businessTypes = BusinessTypes.Where(businessType => businessType.Name == name);
            if (withoutDeleted)
            {
                businessTypes = businessTypes.Where(businessType => businessType.IsDeleted == false);
            }
            return businessTypes.FirstOrDefault();
        }

        #endregion

        #region CommunicationType

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<CommunicationType> GetAllCommunicationTypes()
        {
            return GetAllCommunicationTypes(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<CommunicationType> GetAllCommunicationTypes(bool withoutDeleted)
        {
            IQueryable<CommunicationType> communicationTypes = CommunicationTypes;
            if (withoutDeleted)
            {
                communicationTypes = communicationTypes.Where(communicationType => communicationType.IsDeleted == false);
            }
            communicationTypes = communicationTypes.OrderBy(communicationType => communicationType.Id);
            return communicationTypes.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public CommunicationType GetCommunicationTypeById(int id)
        {
            return GetCommunicationTypeById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public CommunicationType GetCommunicationTypeById(int id, bool withoutDeleted)
        {
            var communicationTypes = CommunicationTypes.Where(communicationType => communicationType.Id == id);
            if (withoutDeleted)
            {
                communicationTypes = communicationTypes.Where(communicationType => communicationType.IsDeleted == false);
            }
            return communicationTypes.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public CommunicationType GetCommunicationTypeByName(string name)
        {
            return GetCommunicationTypeByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public CommunicationType GetCommunicationTypeByName(string name, bool withoutDeleted)
        {
            var communicationTypes = CommunicationTypes.Where(communicationType => communicationType.Name == name);
            if (withoutDeleted)
            {
                communicationTypes = communicationTypes.Where(communicationType => communicationType.IsDeleted == false);
            }
            return communicationTypes.FirstOrDefault();
        }

        #endregion

        #region DealingReason

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<DealingReason> GetAllDealingReasons()
        {
            return GetAllDealingReasons(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<DealingReason> GetAllDealingReasons(bool withoutDeleted)
        {
            IQueryable<DealingReason> dealingReasons = DealingReasons;
            if (withoutDeleted)
            {
                dealingReasons = dealingReasons.Where(dealingReason => dealingReason.IsDeleted == false);
            }
            dealingReasons = dealingReasons.OrderBy(dealingReason => dealingReason.Id);
            return dealingReasons.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public DealingReason GetDealingReasonById(int id)
        {
            return GetDealingReasonById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public DealingReason GetDealingReasonById(int id, bool withoutDeleted)
        {
            var dealingReasons = DealingReasons.Where(dealingReason => dealingReason.Id == id);
            if (withoutDeleted)
            {
                dealingReasons = dealingReasons.Where(dealingReason => dealingReason.IsDeleted == false);
            }
            return dealingReasons.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public DealingReason GetDealingReasonByName(string name)
        {
            return GetDealingReasonByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public DealingReason GetDealingReasonByName(string name, bool withoutDeleted)
        {
            var dealingReasons = DealingReasons.Where(dealingReason => dealingReason.Name == name);
            if (withoutDeleted)
            {
                dealingReasons = dealingReasons.Where(dealingReason => dealingReason.IsDeleted == false);
            }
            return dealingReasons.FirstOrDefault();
        }

        #endregion

        #region DeliveryMode

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<DeliveryMode> GetAllDeliveryModes()
        {
            return GetAllDeliveryModes(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<DeliveryMode> GetAllDeliveryModes(bool withoutDeleted)
        {
            IQueryable<DeliveryMode> deliveryModes = DeliveryModes;
            if (withoutDeleted)
            {
                deliveryModes = deliveryModes.Where(deliveryMode => deliveryMode.IsDeleted == false);
            }
            deliveryModes = deliveryModes.OrderBy(deliveryMode => deliveryMode.Id);
            return deliveryModes.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public DeliveryMode GetDeliveryModeById(int id)
        {
            return GetDeliveryModeById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public DeliveryMode GetDeliveryModeById(int id, bool withoutDeleted)
        {
            var deliveryModes = DeliveryModes.Where(deliveryMode => deliveryMode.Id == id);
            if (withoutDeleted)
            {
                deliveryModes = deliveryModes.Where(deliveryMode => deliveryMode.IsDeleted == false);
            }
            return deliveryModes.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public DeliveryMode GetDeliveryModeByName(string name)
        {
            return GetDeliveryModeByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public DeliveryMode GetDeliveryModeByName(string name, bool withoutDeleted)
        {
            var deliveryModes = DeliveryModes.Where(deliveryMode => deliveryMode.Name == name);
            if (withoutDeleted)
            {
                deliveryModes = deliveryModes.Where(deliveryMode => deliveryMode.IsDeleted == false);
            }
            return deliveryModes.FirstOrDefault();
        }

        #endregion

        #region InformationSource

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<InformationSource> GetAllInformationSources()
        {
            return GetAllInformationSources(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<InformationSource> GetAllInformationSources(bool withoutDeleted)
        {
            IQueryable<InformationSource> informationSources = InformationSources;
            if (withoutDeleted)
            {
                informationSources = informationSources.Where(informationSource => informationSource.IsDeleted == false);
            }
            informationSources = informationSources.OrderBy(informationSource => informationSource.Id);
            return informationSources.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public InformationSource GetInformationSourceById(int id)
        {
            return GetInformationSourceById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public InformationSource GetInformationSourceById(int id, bool withoutDeleted)
        {
            var informationSources = InformationSources.Where(informationSource => informationSource.Id == id);
            if (withoutDeleted)
            {
                informationSources = informationSources.Where(informationSource => informationSource.IsDeleted == false);
            }
            return informationSources.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public InformationSource GetInformationSourceByName(string name)
        {
            return GetInformationSourceByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public InformationSource GetInformationSourceByName(string name, bool withoutDeleted)
        {
            var informationSources = InformationSources.Where(informationSource => informationSource.Name == name);
            if (withoutDeleted)
            {
                informationSources = informationSources.Where(informationSource => informationSource.IsDeleted == false);
            }
            return informationSources.FirstOrDefault();
        }

        #endregion

        #region Facility

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<Facility> GetAllFacilities()
        {
            return GetAllFacilities(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<Facility> GetAllFacilities(bool withoutDeleted)
        {
            IQueryable<Facility> facilities = Facilities;
            if (withoutDeleted)
            {
                facilities = facilities.Where(facility => facility.IsDeleted == false);
            }
            facilities = facilities.OrderBy(facility => facility.Id);
            return facilities.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public Facility GetFacilityById(int id)
        {
            return GetFacilityById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public Facility GetFacilityById(int id, bool withoutDeleted)
        {
            var facilities = Facilities.Where(facility => facility.Id == id);
            if (withoutDeleted)
            {
                facilities = facilities.Where(facility => facility.IsDeleted == false);
            }
            return facilities.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public Facility GetFacilityByName(string name)
        {
            return GetFacilityByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public Facility GetFacilityByName(string name, bool withoutDeleted)
        {
            var facilities = Facilities.Where(facility => facility.Name == name);
            if (withoutDeleted)
            {
                facilities = facilities.Where(facility => facility.IsDeleted == false);
            }
            return facilities.FirstOrDefault();
        }

        #endregion

        #region LeasePaymentType

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<LeasePaymentType> GetAllLeasePaymentTypes()
        {
            return GetAllLeasePaymentTypes(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<LeasePaymentType> GetAllLeasePaymentTypes(bool withoutDeleted)
        {
            IQueryable<LeasePaymentType> leasePaymentTypes = LeasePaymentTypes;
            if (withoutDeleted)
            {
                leasePaymentTypes = leasePaymentTypes.Where(leasePaymentType => leasePaymentType.IsDeleted == false);
            }
            leasePaymentTypes = leasePaymentTypes.OrderBy(leasePaymentType => leasePaymentType.Id);
            return leasePaymentTypes.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public LeasePaymentType GetLeasePaymentTypeById(int id)
        {
            return GetLeasePaymentTypeById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public LeasePaymentType GetLeasePaymentTypeById(int id, bool withoutDeleted)
        {
            var leasePaymentTypes = LeasePaymentTypes.Where(leasePaymentType => leasePaymentType.Id == id);
            if (withoutDeleted)
            {
                leasePaymentTypes = leasePaymentTypes.Where(leasePaymentType => leasePaymentType.IsDeleted == false);
            }
            return leasePaymentTypes.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public LeasePaymentType GetLeasePaymentTypeByName(string name)
        {
            return GetLeasePaymentTypeByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public LeasePaymentType GetLeasePaymentTypeByName(string name, bool withoutDeleted)
        {
            var leasePaymentTypes = LeasePaymentTypes.Where(leasePaymentType => leasePaymentType.Name == name);
            if (withoutDeleted)
            {
                leasePaymentTypes = leasePaymentTypes.Where(leasePaymentType => leasePaymentType.IsDeleted == false);
            }
            return leasePaymentTypes.FirstOrDefault();
        }

        #endregion

        #region Motivation

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<Motivation> GetAllMotivations()
        {
            return GetAllMotivations(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<Motivation> GetAllMotivations(bool withoutDeleted)
        {
            IQueryable<Motivation> motivations = Motivations;
            if (withoutDeleted)
            {
                motivations = motivations.Where(motivation => motivation.IsDeleted == false);
            }
            motivations = motivations.OrderBy(motivation => motivation.Id);
            return motivations.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public Motivation GetMotivationById(int id)
        {
            return GetMotivationById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public Motivation GetMotivationById(int id, bool withoutDeleted)
        {
            var motivations = Motivations.Where(motivation => motivation.Id == id);
            if (withoutDeleted)
            {
                motivations = motivations.Where(motivation => motivation.IsDeleted == false);
            }
            return motivations.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public Motivation GetMotivationByName(string name)
        {
            return GetMotivationByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public Motivation GetMotivationByName(string name, bool withoutDeleted)
        {
            var motivations = Motivations.Where(motivation => motivation.Name == name);
            if (withoutDeleted)
            {
                motivations = motivations.Where(motivation => motivation.IsDeleted == false);
            }
            return motivations.FirstOrDefault();
        }

        #endregion

        #region PaymentType

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<PaymentType> GetAllPaymentTypes()
        {
            return GetAllPaymentTypes(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<PaymentType> GetAllPaymentTypes(bool withoutDeleted)
        {
            IQueryable<PaymentType> paymentTypes = PaymentTypes;
            if (withoutDeleted)
            {
                paymentTypes = paymentTypes.Where(paymentType => paymentType.IsDeleted == false);
            }
            paymentTypes = paymentTypes.OrderBy(paymentType => paymentType.Id);
            return paymentTypes.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public PaymentType GetPaymentTypeById(int id)
        {
            return GetPaymentTypeById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public PaymentType GetPaymentTypeById(int id, bool withoutDeleted)
        {
            var paymentTypes = PaymentTypes.Where(paymentType => paymentType.Id == id);
            if (withoutDeleted)
            {
                paymentTypes = paymentTypes.Where(paymentType => paymentType.IsDeleted == false);
            }
            return paymentTypes.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public PaymentType GetPaymentTypeByName(string name)
        {
            return GetPaymentTypeByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public PaymentType GetPaymentTypeByName(string name, bool withoutDeleted)
        {
            var paymentTypes = PaymentTypes.Where(paymentType => paymentType.Name == name);
            if (withoutDeleted)
            {
                paymentTypes = paymentTypes.Where(paymentType => paymentType.IsDeleted == false);
            }
            return paymentTypes.FirstOrDefault();
        }

        #endregion

        #region PriceRange

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<PriceRange> GetAllPriceRanges()
        {
            return GetAllPriceRanges(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<PriceRange> GetAllPriceRanges(bool withoutDeleted)
        {
            IQueryable<PriceRange> priceRanges = PriceRanges;
            if (withoutDeleted)
            {
                priceRanges = priceRanges.Where(priceRange => priceRange.IsDeleted == false);
            }
            priceRanges = priceRanges.OrderBy(priceRange => priceRange.Id);
            return priceRanges.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public PriceRange GetPriceRangeById(int id)
        {
            return GetPriceRangeById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public PriceRange GetPriceRangeById(int id, bool withoutDeleted)
        {
            var priceRanges = PriceRanges.Where(priceRange => priceRange.Id == id);
            if (withoutDeleted)
            {
                priceRanges = priceRanges.Where(priceRange => priceRange.IsDeleted == false);
            }
            return priceRanges.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public PriceRange GetPriceRangeByName(string name)
        {
            return GetPriceRangeByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public PriceRange GetPriceRangeByName(string name, bool withoutDeleted)
        {
            var priceRanges = PriceRanges.Where(priceRange => priceRange.Name == name);
            if (withoutDeleted)
            {
                priceRanges = priceRanges.Where(priceRange => priceRange.IsDeleted == false);
            }
            return priceRanges.FirstOrDefault();
        }

        #endregion

        #region ProjectState

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<ProjectState> GetAllProjectStates()
        {
            return GetAllProjectStates(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<ProjectState> GetAllProjectStates(bool withoutDeleted)
        {
            IQueryable<ProjectState> projectStates = ProjectStates;
            if (withoutDeleted)
            {
                projectStates = projectStates.Where(projectState => projectState.IsDeleted == false);
            }
            projectStates = projectStates.OrderBy(projectState => projectState.Id);
            return projectStates.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public ProjectState GetProjectStateById(int id)
        {
            return GetProjectStateById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public ProjectState GetProjectStateById(int id, bool withoutDeleted)
        {
            var projectStates = ProjectStates.Where(projectState => projectState.Id == id);
            if (withoutDeleted)
            {
                projectStates = projectStates.Where(projectState => projectState.IsDeleted == false);
            }
            return projectStates.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public ProjectState GetProjectStateByName(string name)
        {
            return GetProjectStateByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public ProjectState GetProjectStateByName(string name, bool withoutDeleted)
        {
            var projectStates = ProjectStates.Where(projectState => projectState.Name == name);
            if (withoutDeleted)
            {
                projectStates = projectStates.Where(projectState => projectState.IsDeleted == false);
            }
            return projectStates.FirstOrDefault();
        }

        #endregion

        #region PropertyState

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<PropertyState> GetAllPropertyStates()
        {
            return GetAllPropertyStates(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<PropertyState> GetAllPropertyStates(bool withoutDeleted)
        {
            IQueryable<PropertyState> roomStates = PropertyStates;
            if (withoutDeleted)
            {
                roomStates = roomStates.Where(roomState => roomState.IsDeleted == false);
            }
            roomStates = roomStates.OrderBy(roomState => roomState.Id);
            return roomStates.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public PropertyState GetPropertyStateById(int id)
        {
            return GetPropertyStateById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public PropertyState GetPropertyStateById(int id, bool withoutDeleted)
        {
            var roomStates = PropertyStates.Where(roomState => roomState.Id == id);
            if (withoutDeleted)
            {
                roomStates = roomStates.Where(roomState => roomState.IsDeleted == false);
            }
            return roomStates.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public PropertyState GetPropertyStateByName(string name)
        {
            return GetPropertyStateByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public PropertyState GetPropertyStateByName(string name, bool withoutDeleted)
        {
            var roomStates = PropertyStates.Where(roomState => roomState.Name == name);
            if (withoutDeleted)
            {
                roomStates = roomStates.Where(roomState => roomState.IsDeleted == false);
            }
            return roomStates.FirstOrDefault();
        }

        #endregion

        #region ReceiptType

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<ReceiptType> GetAllReceiptTypes()
        {
            return GetAllReceiptTypes(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<ReceiptType> GetAllReceiptTypes(bool withoutDeleted)
        {
            IQueryable<ReceiptType> receiptTypes = ReceiptTypes;
            if (withoutDeleted)
            {
                receiptTypes = receiptTypes.Where(receiptType => receiptType.IsDeleted == false);
            }
            receiptTypes = receiptTypes.OrderBy(receiptType => receiptType.Id);
            return receiptTypes.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public ReceiptType GetReceiptTypeById(int id)
        {
            return GetReceiptTypeById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public ReceiptType GetReceiptTypeById(int id, bool withoutDeleted)
        {
            var receiptTypes = ReceiptTypes.Where(receiptType => receiptType.Id == id);
            if (withoutDeleted)
            {
                receiptTypes = receiptTypes.Where(receiptType => receiptType.IsDeleted == false);
            }
            return receiptTypes.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public ReceiptType GetReceiptTypeByName(string name)
        {
            return GetReceiptTypeByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public ReceiptType GetReceiptTypeByName(string name, bool withoutDeleted)
        {
            var receiptTypes = ReceiptTypes.Where(receiptType => receiptType.Name == name);
            if (withoutDeleted)
            {
                receiptTypes = receiptTypes.Where(receiptType => receiptType.IsDeleted == false);
            }
            return receiptTypes.FirstOrDefault();
        }

        #endregion

        #region ReportType

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<ReportType> GetAllReportTypes()
        {
            return GetAllReportTypes(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<ReportType> GetAllReportTypes(bool withoutDeleted)
        {
            IQueryable<ReportType> reportTypes = ReportTypes;
            if (withoutDeleted)
            {
                reportTypes = reportTypes.Where(reportType => reportType.IsDeleted == false);
            }
            reportTypes = reportTypes.OrderBy(reportType => reportType.Id);
            return reportTypes.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public ReportType GetReportTypeById(int id)
        {
            return GetReportTypeById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public ReportType GetReportTypeById(int id, bool withoutDeleted)
        {
            var reportTypes = ReportTypes.Where(reportType => reportType.Id == id);
            if (withoutDeleted)
            {
                reportTypes = reportTypes.Where(reportType => reportType.IsDeleted == false);
            }
            return reportTypes.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public ReportType GetReportTypeByName(string name)
        {
            return GetReportTypeByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public ReportType GetReportTypeByName(string name, bool withoutDeleted)
        {
            var reportTypes = ReportTypes.Where(reportType => reportType.Name == name);
            if (withoutDeleted)
            {
                reportTypes = reportTypes.Where(reportType => reportType.IsDeleted == false);
            }
            return reportTypes.FirstOrDefault();
        }

        #endregion

        #region RequirementLevel

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<RequirementLevel> GetAllRequirementLevels()
        {
            return GetAllRequirementLevels(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<RequirementLevel> GetAllRequirementLevels(bool withoutDeleted)
        {
            IQueryable<RequirementLevel> requirementLevels = RequirementLevels;
            if (withoutDeleted)
            {
                requirementLevels = requirementLevels.Where(requirementLevel => requirementLevel.IsDeleted == false);
            }
            requirementLevels = requirementLevels.OrderBy(requirementLevel => requirementLevel.Id);
            return requirementLevels.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public RequirementLevel GetRequirementLevelById(int id)
        {
            return GetRequirementLevelById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public RequirementLevel GetRequirementLevelById(int id, bool withoutDeleted)
        {
            var requirementLevels = RequirementLevels.Where(requirementLevel => requirementLevel.Id == id);
            if (withoutDeleted)
            {
                requirementLevels = requirementLevels.Where(requirementLevel => requirementLevel.IsDeleted == false);
            }
            return requirementLevels.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public RequirementLevel GetRequirementLevelByName(string name)
        {
            return GetRequirementLevelByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public RequirementLevel GetRequirementLevelByName(string name, bool withoutDeleted)
        {
            var requirementLevels = RequirementLevels.Where(requirementLevel => requirementLevel.Name == name);
            if (withoutDeleted)
            {
                requirementLevels = requirementLevels.Where(requirementLevel => requirementLevel.IsDeleted == false);
            }
            return requirementLevels.FirstOrDefault();
        }

        #endregion

        #region Resistance

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<Resistance> GetAllResistances()
        {
            return GetAllResistances(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<Resistance> GetAllResistances(bool withoutDeleted)
        {
            IQueryable<Resistance> resistances = Resistances;
            if (withoutDeleted)
            {
                resistances = resistances.Where(resistance => resistance.IsDeleted == false);
            }
            resistances = resistances.OrderBy(resistance => resistance.Id);
            return resistances.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public Resistance GetResistanceById(int id)
        {
            return GetResistanceById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public Resistance GetResistanceById(int id, bool withoutDeleted)
        {
            var resistances = Resistances.Where(resistance => resistance.Id == id);
            if (withoutDeleted)
            {
                resistances = resistances.Where(resistance => resistance.IsDeleted == false);
            }
            return resistances.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public Resistance GetResistanceByName(string name)
        {
            return GetResistanceByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public Resistance GetResistanceByName(string name, bool withoutDeleted)
        {
            var resistances = Resistances.Where(resistance => resistance.Name == name);
            if (withoutDeleted)
            {
                resistances = resistances.Where(resistance => resistance.IsDeleted == false);
            }
            return resistances.FirstOrDefault();
        }

        #endregion

        #region Role

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<Role> GetAllRoles()
        {
            return GetAllRoles(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<Role> GetAllRoles(bool withoutDeleted)
        {
            IQueryable<Role> roles = Roles;
            if (withoutDeleted)
            {
                roles = roles.Where(role => role.IsDeleted == false);
            }
            roles = roles.OrderBy(role => role.Id);
            return roles.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public Role GetRoleById(int id)
        {
            return GetRoleById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public Role GetRoleById(int id, bool withoutDeleted)
        {
            var roles = Roles.Where(role => role.Id == id);
            if (withoutDeleted)
            {
                roles = roles.Where(role => role.IsDeleted == false);
            }
            return roles.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public Role GetRoleByName(string name)
        {
            return GetRoleByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public Role GetRoleByName(string name, bool withoutDeleted)
        {
            var roles = Roles.Where(role => role.Name == name);
            if (withoutDeleted)
            {
                roles = roles.Where(role => role.IsDeleted == false);
            }
            return roles.FirstOrDefault();
        }

        #endregion

        #region RoomState

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<RoomState> GetAllRoomStates()
        {
            return GetAllRoomStates(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<RoomState> GetAllRoomStates(bool withoutDeleted)
        {
            IQueryable<RoomState> roomStates = RoomStates;
            if (withoutDeleted)
            {
                roomStates = roomStates.Where(roomState => roomState.IsDeleted == false);
            }
            roomStates = roomStates.OrderBy(roomState => roomState.Id);
            return roomStates.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public RoomState GetRoomStateById(int id)
        {
            return GetRoomStateById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public RoomState GetRoomStateById(int id, bool withoutDeleted)
        {
            var roomStates = RoomStates.Where(roomState => roomState.Id == id);
            if (withoutDeleted)
            {
                roomStates = roomStates.Where(roomState => roomState.IsDeleted == false);
            }
            return roomStates.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public RoomState GetRoomStateByName(string name)
        {
            return GetRoomStateByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public RoomState GetRoomStateByName(string name, bool withoutDeleted)
        {
            var roomStates = RoomStates.Where(roomState => roomState.Name == name);
            if (withoutDeleted)
            {
                roomStates = roomStates.Where(roomState => roomState.IsDeleted == false);
            }
            return roomStates.FirstOrDefault();
        }

        #endregion

        #region RoomType

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<RoomType> GetAllRoomTypes()
        {
            return GetAllRoomTypes(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<RoomType> GetAllRoomTypes(bool withoutDeleted)
        {
            IQueryable<RoomType> roomTypes = RoomTypes;
            if (withoutDeleted)
            {
                roomTypes = roomTypes.Where(roomType => roomType.IsDeleted == false);
            }
            roomTypes = roomTypes.OrderBy(roomType => roomType.Id);
            return roomTypes.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public RoomType GetRoomTypeById(int id)
        {
            return GetRoomTypeById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public RoomType GetRoomTypeById(int id, bool withoutDeleted)
        {
            var roomTypes = RoomTypes.Where(roomType => roomType.Id == id);
            if (withoutDeleted)
            {
                roomTypes = roomTypes.Where(roomType => roomType.IsDeleted == false);
            }
            return roomTypes.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public RoomType GetRoomTypeByName(string name)
        {
            return GetRoomTypeByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public RoomType GetRoomTypeByName(string name, bool withoutDeleted)
        {
            var roomTypes = RoomTypes.Where(roomType => roomType.Name == name);
            if (withoutDeleted)
            {
                roomTypes = roomTypes.Where(roomType => roomType.IsDeleted == false);
            }
            return roomTypes.FirstOrDefault();
        }

        #endregion

        #region Usage

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<Usage> GetAllUsages()
        {
            return GetAllUsages(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<Usage> GetAllUsages(bool withoutDeleted)
        {
            IQueryable<Usage> usages = Usages;
            if (withoutDeleted)
            {
                usages = usages.Where(usage => usage.IsDeleted == false);
            }
            usages = usages.OrderBy(usage => usage.Id);
            return usages.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public Usage GetUsageById(int id)
        {
            return GetUsageById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public Usage GetUsageById(int id, bool withoutDeleted)
        {
            var usages = Usages.Where(usage => usage.Id == id);
            if (withoutDeleted)
            {
                usages = usages.Where(usage => usage.IsDeleted == false);
            }
            return usages.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public Usage GetUsageByName(string name)
        {
            return GetUsageByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public Usage GetUsageByName(string name, bool withoutDeleted)
        {
            var usages = Usages.Where(usage => usage.Name == name);
            if (withoutDeleted)
            {
                usages = usages.Where(usage => usage.IsDeleted == false);
            }
            return usages.FirstOrDefault();
        }

        #endregion

        #region WithdrawalReason

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IList<WithdrawalReason> GetAllWithdrawalReasons()
        {
            return GetAllWithdrawalReasons(true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public IList<WithdrawalReason> GetAllWithdrawalReasons(bool withoutDeleted)
        {
            IQueryable<WithdrawalReason> withdrawalReasons = WithdrawalReasons;
            if (withoutDeleted)
            {
                withdrawalReasons = withdrawalReasons.Where(withdrawalReason => withdrawalReason.IsDeleted == false);
            }
            withdrawalReasons = withdrawalReasons.OrderBy(withdrawalReason => withdrawalReason.Id);
            return withdrawalReasons.ToList();
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <returns></returns>
        public WithdrawalReason GetWithdrawalReasonById(int id)
        {
            return GetWithdrawalReasonById(id, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "id"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public WithdrawalReason GetWithdrawalReasonById(int id, bool withoutDeleted)
        {
            var withdrawalReasons = WithdrawalReasons.Where(withdrawalReason => withdrawalReason.Id == id);
            if (withoutDeleted)
            {
                withdrawalReasons = withdrawalReasons.Where(withdrawalReason => withdrawalReason.IsDeleted == false);
            }
            return withdrawalReasons.FirstOrDefault();
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <returns></returns>
        public WithdrawalReason GetWithdrawalReasonByName(string name)
        {
            return GetWithdrawalReasonByName(name, true);
        }

        /// <summary>
        /// </summary>
        /// <param name = "name"></param>
        /// <param name = "withoutDeleted"></param>
        /// <returns></returns>
        public WithdrawalReason GetWithdrawalReasonByName(string name, bool withoutDeleted)
        {
            var withdrawalReasons = WithdrawalReasons.Where(withdrawalReason => withdrawalReason.Name == name);
            if (withoutDeleted)
            {
                withdrawalReasons = withdrawalReasons.Where(withdrawalReason => withdrawalReason.IsDeleted == false);
            }
            return withdrawalReasons.FirstOrDefault();
        }

        #endregion
    }
}